
<script>
    function variables_init(){
        setvariable("field1");
        setvariable("field2");
        setvariable("field3");
    }

    function permission_init(){
        setpermission("field1");
        setpermission("field2");
        setpermission("field3");

        $('.mydetail').show();
    }
    function setvariable(field) {
        if(variables[field]!=undefined)
        {$('#'+field).val(variables[field]);}
    }
    function setpermission(field) {
        var value = permission[field];
        //alert(value);
        if(value!=undefined) {

            if (value == "read") {
                $('#li' + field).find('input').attr("readonly", "readonly");
            } else if (value == "write" || nodeTitle == '开始') {
                $('#li' + field).find('input').removeAttr("readonly");
            } else if (value == "hide") {
                $('#li' + field).remove();
            }
        }
    }
    function form_submit() {
        var variables = {};
        if($('[name="field1"]').val()==''){
            alert('field1 必填');
            return false;
        }
        $('.mydetail input').each(function () {
            if($(this).attr("readonly")!="readonly") {
                var field = $(this).attr("id");
                variables[field]= $(this).val();
            }
        });
        console.log(JSON.stringify(variables));
        //return false;
        return variables;
    }
</script>
<div>
    <ul class="mydetail" style="display: none">
        <li id="lifield1">
            <label>字段1</label>
            <input type="text" class="text midtext" style="width:200px;" readonly="readonly" name="" id="field1" value="" />
        </li>
        <li id="lifield2">
            <label>字段2</label>
            <input type="text" class="text midtext" style="width:200px;" readonly="readonly" name="" id="field2" value="" />
        </li>
        <li id="lifield3">
            <label>字段3</label>
            <input type="text" class="text midtext" style="width:200px;" readonly="readonly" name="" id="field3" value="" />
        </li>
    </ul>
</div>
